package com.fruit.util;

import javax.servlet.http.HttpServletRequest;

public class ParameterUtil {

    public static Integer getInteger(HttpServletRequest request, String name) {
        String str = request.getParameter(name);
        if (str == null || str.trim().length() == 0) {
            return null;
        }
        try {
            return Integer.parseInt(str);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            return null;
        }
    }

    public static Float getFloat(HttpServletRequest request, String name) {
        String str = request.getParameter(name);
        if (str == null || str.trim().length() == 0) {
            return null;
        }
        try {
            return Float.parseFloat(str);
        } catch (NumberFormatException e) {
            e.printStackTrace();
            return null;
        }
    }
}
